<?php
/**
 * Enter description here ...
 * @author Kevin
 * @version 1.0
 * @updated 06-d�c.-2011 23:07:20
 */
abstract class Publication implements I_Persistent
{

	//==================================================================
	// Data
	//==================================================================

	var $id;
	var $type;
	var $owner;
	var $visibility;
	var $date;
	var $hour;
	var $language;
	var $exist = false;		// variable indiquant si la publication existe en base

	//==================================================================
	// Constructors
	//==================================================================
	
	/**
	 * Enter description here ...
	 * @param string $pType : EVENT, COMMENT, etc.
	 * @param int $pId : ID concret de la publication à créer
	 */
	function Publication($pType, $pId){
		global $wpdb;
		
		$this->id = $pId;
		$this->type = $pType;
		
		$_row = 
		$wpdb->get_row(
			$wpdb->prepare(
				// request
				"SELECT * 
				FROM publications 
				WHERE fk_concretid = %d 
				AND fk_concrettype = '%s'",
			
				// params
				$pId,
				$pType
		));		
		
		if($_row->id > 0 ){
			$this->owner = $_row->fk_owner;
			$this->visibility = $_row->fk_visibility;
			$this->date = $_row->date;
			$this->hour = $_row->hour;
			$this->language = $_row->language;

			$this->exist = true;
		}
		
	}

	//==================================================================
	// Methods
	//==================================================================

	//=================================================
	// Methods > Concret 
	//=================================================
	
	//=================================
	// Methods > Concret > Accessors
	//=================================

	/**
	 * Enter description here ...
	 * @return unknown_type
	 */
	function getId(){
		return $this->id;
	}

	/**
	 * Enter description here ...
	 * @return unknown_type
	 */
	function getType(){
		return $this->type;
	}

	/**
	 * Enter description here ...
	 * @return User
	 */
	function getOwner(){
		return new User($this->owner);
	}

	/**
	 * Enter description here ...
	 */
	function getVisibility(){
		return $this->visibility;
	}

	/**
	 * Enter description here ...
	 */
	function getDate(){
		return $this->date;
	}

	/**
	 * Enter description here ...
	 */
	function getHour(){
		return $this->hour;
	}

	/**
	 * Enter description here ...
	 */
	function getLanguage(){
		return $this->language;
	}

	/**
	 * Enter description here ...
	 * @return boolean
	 */
	function getExist(){
		return $this->exist;
	}
	
	//=================================
	// Methods > Concret > Others
	//=================================
	
	/**
	 * Enter description here ...
	 * @return NULL
	 */
	function getComments(){
		global $wpdb;

		return null;
	}
	
	//=================================================
	// Methods > Abstract 
	//=================================================


	/**
	 * Enter description here ...
	 */
	abstract function toHTML();

	
	/**
	* Enter description here ...
	*/
	function signal(){
		
	}
	
	/**
	* Enter description here ...
	*/
	function addComment($pComment){
		
	}

	function createNotification()
	{
	}

	function getUsersToNotify()
	{
	}
}